home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 …SCII & the Runetime Code / ADC Developer CD (1992-07) (''Butch ASCII And The Runtime Code'')_iso / Dev.CD 199207.iso / Development Platforms / Apple II / HyperCardIIGS / Developer Documentation / ASCII Text / HyperCard.ERS next >
Encoding:
Text File  |  1992-02-24  |  39.0 KB  |  1,061 lines  |  [TEXT/pdos]

  1.  
  2.  
  3.  
  4.                                  
  5.  
  6.  
  7. HYPERCARD IIGS 1.1 ERS
  8. c 1991-92 Apple Computer, Inc.  All Rights Reserved
  9.  
  10.  
  11.  
  12. Summary of HyperCard IIGS Version 1.1
  13. Version 1.1 is an enhanced version of HyperCard IIGS version 1.0.  As 
  14. such, it includes all the features of HyperCard IIGS version 1.0 
  15. (referred to hereafter as version 1.0) as well as new features specific 
  16. to version 1.1.  Stacks created with version 1.0 are 100% compatible 
  17. with version 1.1.  Stacks created with the later version will continue 
  18. to function with version 1.0 provided the stacks do not take advantage 
  19. of features specific to version 1.1.  Stacks that use the new HyperTalk 
  20. features of 1.1 will generate HyperTalk errors if run under version 1.0.
  21.  
  22. HyperCard IIgs 1.1 is designed to function with the same memory 
  23. requirements as version 1.0.  It requires an Apple IIGS with at least 
  24. 1.5 megabytes of memory and a hard disk.  
  25.  
  26. Version 1.1 is System Software 6.0 aware and takes advantage of several 
  27. new system software features.  Version 1.1 will continue to run with 
  28. System Software 5.0.4 as did HyperCard IIgs version 1.0.
  29.  
  30. The new features of version 1.1 are designed to provide easier access to 
  31. commonly used scripting techniques, implement the most useful/practical 
  32. of the Macintosh HyperCard 2.1 features, provide a further 
  33. implementation of color, and take advantage of new features in System 
  34. Software.
  35.  
  36. Bugs fixed in version 1.1 consist of all known crashing bugs as well as 
  37. any bugs fixable within the scope of the 1.1 release.
  38.  
  39.  
  40. Version 1.1 Features
  41. This section describes all the new features of HyperCard IIgs 1.1 as 
  42. well as comparing them to similar or identical features of Macintosh 
  43. HyperCard 2.0/2.1.  The list below is comprised of visual changes as 
  44. well as discernible feature changes.  It does not include changes such 
  45. as speed enhancements or bug fixes which are included in a separate 
  46. section.
  47.  
  48. New property - "ItemDelimiter"
  49. This new property allows the scripter to define any single character as 
  50. the delimiter character used to separate items in HyperTalk containers.  
  51. For example, the scripter wishes to locate the filename from within a 
  52. container that contains a complete pathname.  Using version 1.1 and the 
  53. itemDelimiter property, the scripter can do this:
  54.  
  55. Variable "bucket" contains:
  56.     :Barney:HyperCard:Stacks:MyOwnStack
  57.  
  58. The user executes the following script:
  59.     set the itemDelimiter to colon
  60.     put last item of bucket
  61.  
  62. Version 1.1 responds with:
  63.     MyOwnStack
  64.  
  65. The itemDelimiter property resets to the comma character at idle time so 
  66. as not to affect compatibility with stacks that assume the itemDelimiter 
  67. character is always a comma.  This property is identical to HyperCard 
  68. 2.1.
  69.  
  70.  
  71. New constants - "Comma" and "Colon"
  72. Version 1.1 contains two new HyperTalk constants.  They are "colon" and 
  73. "comma."  These constants are designed to compliment the new 
  74. itemDelimiter property.
  75.  
  76. The user can now script:
  77.     Set the itemDelimiter to colon
  78.     or
  79.     Set the itemDelimiter to comma
  80.  
  81. Instead of:
  82.     Set the itemDelimiter to ":"
  83.     or
  84.     Set the itemDelimiter to ","
  85.  
  86. Note that the scripter is not restricted to using these constants and 
  87. can use any HyperTalk character or expression to define the 
  88. itemDelimiter character.
  89.  
  90. Feature enhancement - "Compact Stack"
  91. Compacting a stack with free space in the resource fork caused by adding 
  92. and deleting resources will now compact the resource fork as well as the 
  93. data fork when the user chooses the Compact Stack menu item if:  (a)  
  94. the user holds down the option key, (b) the free space is > 50K, or (c) 
  95. the free space is > 10% of the resource fork size.
  96.  
  97. Command enhancement - "Ask"
  98. The "Ask" command has been enhanced to return "Cancel" if the user 
  99. clicks the cancel button in addition to returning empty in the variable 
  100. "it."  
  101.  
  102. The user can now script:
  103.     ask "Please enter your name:"
  104.     if the result is not "Cancel" then
  105.       put it into userName
  106.     end if
  107.  
  108. Property change - "Rect, top, topLeft, location"
  109. The rect property of windows has been altered to be compatible with 
  110. Macintosh HyperCard.  HyperCard IIGS 1.0 would return a rect with the 
  111. top left corner starting at the top left of the window frame.  HyperCard 
  112. IIgs 1.1 and all versions of Macintosh HyperCard return the top left 
  113. corner of the content region.  The same applies when setting the top, 
  114. location, or topLeft of a window.  The coordinates specified define the 
  115. top left of the content region.  Scripts from HyperCard IIGS 1.0 that 
  116. specifically set a window to a certain location will cause the window to 
  117. appear six pixels higher than it did running under HyperCard IIgs 1.0.  
  118. This can be easily changed in the particular script.
  119.  
  120.  
  121. New property - "BackColor"
  122. A new property named "BackColor" has been added to fields and buttons.  
  123. This property determines the background color of a button or field.  
  124. HyperCard IIGS 1.0 is restricted to white backgrounds.
  125.  
  126. The user can access this new property with the following:
  127.     set the backColor of button 1 to 15
  128.     or
  129.     set the backcolor of last field to 5
  130.  
  131. The backColor property is limited to an integer between 1 and 16 
  132. representing one of the sixteen colors available to user on that 
  133. particular card/background.  This property can also be accessed and 
  134. changed from the revised object color dialog boxes.
  135.  
  136. Changed dialog boxes - "Field Colors" and "Button Colors"
  137. The dialog boxes which allow the user to view and modify the color 
  138. attributes of buttons and fields have been altered significantly.  
  139. Included on the next page are screenshots of the new dialog boxes.
  140.  
  141.                                                               
  142.  
  143. Open File "HCGS.1" to see Figure 1 - HyperCard IIGS Field Colors Dialog
  144.  
  145.  
  146.                                                               
  147.  
  148. Open File "HCGS.2" to see Figure 2 - HyperCard IIGS Button Colors Dialog
  149.  
  150.  
  151. Feature Enhancement - "Transparency"
  152. The new backColor property interacts with transparent buttons and fields 
  153. to provide "tinted" buttons/fields similar to a stained glass effect.  
  154. Setting the backColor of a transparent button or field causes the 
  155. background of the part to be translucent, allowing objects behind the 
  156. part to show through to the foreground.  The choice of backColor 
  157. determines how the objects underneath show through and how they are 
  158. tinted.  Transparent objects created with version 1.0 always have a 
  159. backColor of white which is not affected by this feature.  Transparent 
  160. objects with a white background color will function identically to 
  161. version 1.0.
  162.  
  163. New Functions - "ClickLine" and "ClickChunk"
  164. Version 1.1 contains two new functions that allow the scripter to easily 
  165. determine where in a particular field a user clicked.
  166.  
  167. Syntax for the clickLine, clickChunk functions:
  168.     put the clickLine
  169.     put the clickChunk
  170. Or
  171.     put clickLine()
  172.     put clickChunk()
  173.  
  174. ClickLine returns the line clicked in this format:
  175.     line 3 of card field 1
  176.  
  177. ClickChunk returns a chunk expression defining the text clicked on in 
  178. this form:
  179.     char 5 to 9 of bkgnd field 6
  180.  
  181. ClickLine returns the line clicked relative to the actual text of the 
  182. field, not the way the text is word wrapped.  Therefore, a user can 
  183. click on the text on the second line of a field and have line one 
  184. returned since the first line of the field was long enough to wrap to 
  185. the second display line.  These functions are identical in 
  186. implementation to these functions in Macintosh HyperCard 2.0/2.1.
  187.  
  188. System Software 6.0 support
  189. HyperCard IIgs 1.1 contains several features specific to the 6.0 
  190. environment.  If running under System Software 5.0.4, these features 
  191. will not be available.
  192.  
  193.     Detect disk insertions
  194.     Version 1.1 will now detect disk insertions and respond 
  195.     appropriately at idle time.  If the disk is unreadable, a 
  196.     dialog box will be displayed asking the user if they wish 
  197.     to format the disk.
  198.  
  199.     Launching under System Software 6.0
  200.     HyperCard IIgs 1.1 will not drop out of the SHR screen while 
  201.     launching, executing another GS/OS application, or quitting 
  202.     to the Finder.
  203.  
  204.     Finder support
  205.     Version 1.1 contains Finder "info" resources containing icon, 
  206.     version, and copyright information as well as document types 
  207.     and paths.
  208.  
  209.     Command enhancement - "Play"
  210.     The Play" command has been enhanced to work in conjunction 
  211.     with the new 6.0 Sound Control Panel.  If 6.0 is in use and the 
  212.     user attempts to play a sound that is not present in the 
  213.     current resource heirarchy, version 1.1 will query the 
  214.     Sound Control Panel to determine if a sound with that name 
  215.     exists in the Sounds folder of the boot disk.  If it does, 
  216.     version 1.1 will play the sound just as if it was present in a
  217.     resource.  This process will be transparent to the end user. 
  218.  
  219. XWindows
  220. HyperCard IIgs 1.1 implements a subset of the XWindow concept from 
  221. Macintosh HyperCard 2.0/2.1.  Certain concepts such as those dealing 
  222. with an externally based script editor as in 2.0/2.1 are not 
  223. implemented.  The list below details the XWindow implementation of 
  224. HyperCard IIgs version 1.1.
  225.  
  226.  
  227. HyperTalk Extensions
  228. HyperCard IIgs 1.1 HyperTalk has been extended to include support for 
  229. moving, hiding, showing, and otherwise manipulating XWindows as easily 
  230. as the built-in windows such as the Tool, Pattern, and Go palettes.  In 
  231. addition, HyperTalk support for the built-in windows is improved and 
  232. expanded.  All the original methods of dealing with windows remain 
  233. intact and unchanged.
  234.  
  235. New Method of Referencing Windows - by Name, Number, or Ordinal.
  236. Version 1.1 now supports referencing windows, both built-in and 
  237. external, in several new ways.  These new ways of referencing the 
  238. windows are compatible with 2.0/2.1.  Referencing a window in HyperCard 
  239. IIGS 1.0/HyperCard 1.2.5 was restricted to this:
  240.     show tool window
  241.  
  242. Although this still functions, it is now possible to reference a window 
  243. in any one of the following methods:
  244.     show tool window
  245.     hide window tool
  246.     show window "tool"
  247.     close window "Fred"  <---- Assuming there is a window named "Fred"
  248.     set the location of first window to 50,50
  249.     get the visible of sixth window
  250.     show last window
  251.     show window 3
  252.     show window id 69341 at 50,30
  253.     hide any window
  254.  
  255. All of the existing commands and functions dealing with windows as well 
  256. as all new commands and functions now support this method of referencing 
  257. windows.  Note that only the built-in windows (Tool, Pattern, Card, and 
  258. Go) can be referenced in the old form of "<name> window."
  259.  
  260.  
  261.                                              
  262.  
  263. Open File "HCGS.3" to see Figure 3 - HyperCard IIGS Windows
  264.  
  265.  
  266. New Function - "windows"
  267. Version 1.1 implements a new function which returns a return-delimited 
  268. list of all windows currently available. This is 2.0/2.1 compatible.  A 
  269. typical result of this function is below:
  270.     Message
  271.     Home      <------ The name of the card window is the current stack.
  272.     Pattern
  273.     Tool
  274.     Go
  275.  
  276. Extension to Existing Function - "number of windows"
  277. In addition to being able to determine the number of cards, bkgnds, 
  278. parts, etc.  version 1.1 can now report the number of available windows.  
  279. This is 2.0/2.1 compatible.  This number is the number of HyperCard 
  280. windows, it does not include DA windows or any others.
  281.  
  282. The user can script:
  283.     put the number of windows
  284.  
  285. HyperCard IIgs 1.1 responds with:
  286.     5
  287.  
  288. Extension to Existing Command "set"
  289. Version 1.1 implements all of the properties previously supported for 
  290. built-in windows for external windows as well.  This includes location, 
  291. topLeft, location, visible, etc.  This is identical to 2.0/2.1.
  292.  
  293.  
  294. Extension to Existing Command "Dial with Modem"
  295. Executing the dial with modem command now attempts to dial the phone 
  296. with a serial or modem card if the built-in modem port is disabled.  The 
  297. logic for the dial command is this:
  298. 1) Look for the modem port, if slot 2 is set to "modem", send the modem 
  299.      dialing string out the built-in port.
  300. 2) If the built-in modem port is disabled, look for a character device 
  301.      in slot 2.  If found, send the modem dialing string to that card.
  302. 3) If the built-in port is disabled and slot 2 does not contain a 
  303.      character device, scan for a character device beginning at slot 1 and 
  304.      send the dialing command to the first one found.
  305.  
  306. Extension to Existing Command "Play"
  307. Version 1.1 will now play any sound in the Sounds folder when using 
  308. System 6.0.  If a play command is given using a sound that is not in the 
  309. current resource heirarchy, HyperCard IIGS v.1.1 will call the Sound 
  310. CDEV  of  System 6.0 to determine whether a sound of that name exists 
  311. in the  folder.  If so, it is loaded and used just as any sound resource 
  312. would be.
  313.  
  314. New Window Property - "Name"
  315. Version 1.1 now supports the read-only window property "name."  This 
  316. allows the user to determine a window name.  Commonly used when the user 
  317. only knows the window number.
  318.  
  319. The user can script:
  320.     put the name of <windowReference>
  321.  
  322. HyperCard IIgs version 1.1 responds with something like:
  323.     Pattern
  324.  
  325. New Window Property - "Number"
  326. Version 1.1 now supports the read-only window property "number."  This 
  327. allows the user to determine a window number.  Commonly used when the 
  328. user only knows the window name.
  329.  
  330. The user can script:
  331.     put the number of <windowReference>
  332.  
  333. HyperCard IIgs version 1.1 responds with something like:
  334.     5
  335.  
  336. New Window Property - "ID"
  337. Version 1.1 now supports the read-only window property "ID."  This 
  338. allows the user to determine the ID of a given window.  There are 
  339. several things to note regarding window IDs.  IDs for the built-in 
  340. windows are assigned when HyperCard IIgs starts up and will not change.  
  341. XWindow IDs are assigned when the window is created and released when 
  342. the window is closed.  Window IDs may vary for any window from machine 
  343. to machine.
  344.  
  345. The user can script:
  346.     put the id of <windowReference>
  347.  
  348. HyperCard IIgs version 1.1 responds with something like:
  349.     69341
  350.  
  351. Extension to Existing Command - "Close"
  352. The Close command has been extended to included support for closing 
  353. external windows as well as closing text files and printing jobs.  Only 
  354. external windows may be closed.  Attempting to close a built-in window 
  355. will result in the error message "Can't close that window."  Syntax for 
  356. closing external windows is:
  357.     close <windowReference>
  358.  
  359. The Close command supports all forms of window references and is 
  360. HyperCard 2.0/2.1 compatible.
  361.  
  362.  
  363. Extensions to the XCMD Interface
  364. Version 1.1 contains several new callbacks dealing with the 
  365. implementation of XWindows as well as related utility callbacks.  These 
  366. callbacks are accessed with a set of new HyperXCMD interfaces files 
  367. providing access to the callbacks from Pascal, C, and Assembly Language.  
  368. As many of the new callbacks as possible are modeled after their 
  369. Macintosh HyperCard 2.0/2.1 counterparts within the scope of our XWindow 
  370. implementation.  Following is a list and general description of the new 
  371. callbacks.
  372.  
  373. New Callback - "StrToRect"
  374. PROCEDURE StrToRect(str: Str255; VAR rct: Rect);
  375.     Inputs    str    String containing text to convert to a rect
  376.     Outputs    rct    Rect containing specified coordinates
  377. This callback converts a Pascal string containing alphanumeric 
  378. characters delimited by commas designating a rectangle to a true, four 
  379. integer rect record.  Pascal interface is above.
  380.  
  381. New Callback - "RectToStr"
  382. PROCEDURE RectToStr(rct: Rect; VAR str: Str255);
  383.     Inputs    rct    Rect containing coordinates to convert
  384.     Outputs    str    String containing alphanumeric representation
  385.              of rect
  386. The complement of StrToRect, this callback converts a rect record back 
  387. to a string.
  388.  
  389. New Callback - "StrToPoint"
  390. PROCEDURE StrToPoint(str: Str255; VAR pt: Point);
  391.     Inputs    str    String containing text to convert to a point
  392.     Outputs    pt    Point containing specified coordinates
  393. This callback converts a Pascal string containing alphanumeric 
  394. characters delimited by commas designating a point to a true, two 
  395. integer point record.
  396.  
  397. New Callback - "PointToStr"
  398. PROCEDURE PointToStr(pt: Point; VAR str: Str255);
  399.     Inputs    pt    Point containing coordinates to convert
  400.     Outputs    str    String containing alphanumeric representation
  401.              of point
  402. The complement of StrToPoint, this callback converts a point record back 
  403. to a string.
  404.  
  405. New Callback - "NewXWindow"
  406. FUNCTION NewXWindow(boundsRect: Rect; windName: Str31 
  407.                     visible: BOOLEAN, windowStyle: INTEGER): WindowPtr;
  408.     Inputs    boundsRect    Rect for newly created window
  409.         windName    Name used for HyperTalk references to
  410.                  the window and, optionally, displayed
  411.                  depending on the window type.
  412.         visible        Whether to create the new window 
  413.                 initially visible
  414.         windowStyle    Style of the XWindow.  0 = windoid, 1 = 
  415.                 rectangle, 2 = shadow, 3 = dialog box.
  416.     Outputs    windowPtr    Pointer to a standard window record 
  417.                 defining the new window.
  418. This callback allows an external command to create and register a 
  419. window.  In addition to creating the window, HyperCard also adds the new 
  420. window to its internal list of external windows and keeps the XCMD in 
  421. memory after it terminates so that it can respond to events concerning 
  422. the window.  The windows created are standard IIGS windows and can be 
  423. manipulated in the same way as a window created from within a stand-
  424. alone application with two exceptions.
  425. (1)  The XCMD must never call the toolbox routine CloseWindow on the 
  426. XWindow.  External commands MUST use the CloseXWindow callback to 
  427. dispose of a window.
  428. (2)  External commands must not alter the wRefCon field of the window 
  429. record.  This field is reserved for HyperCard.  External commands 
  430. needing to save or restore data associated with a particular window can 
  431. use the SetXWindowValue and GetXWindowValue callbacks.
  432.  
  433. New Callback - "CloseXWindow"
  434. PROCEDURE CloseXWindow(window: WindowPtr);
  435.     Inputs    window    Pointer to a window record designating the 
  436.             window to be closed
  437.     Outputs    <none>
  438. This callback send an xCloseEvt to the owner external, closes the 
  439. window, and disposes of all memory HyperCard has allocated for the 
  440. window.  XCMDs that create windows are responsible for disposing of any 
  441. memory they have allocated when they receive an xCloseEvt.
  442.  
  443. New Callback - "SetXWindowValue"
  444. PROCEDURE SetXWindowValue(window: WindowPtr; customValue: LongInt);
  445.     Inputs    window        Pointer to window associated with the 
  446.                 value
  447.         customValue    Four byte value containing data to 
  448.                 store with the window
  449.     Outputs    <none>
  450. This callback allows an external command to store a four byte value 
  451. along with any XWindow.  This value will typically be a pointer or 
  452. handle to a block of memory containing information the external command 
  453. wishes to keep intact regarding the contents of the XWindow.  Because 
  454. external commands can execute and terminate many times in response to 
  455. events, data cannot be kept in standard variables.
  456.  
  457. New Callback - "GetXWindowValue"
  458. FUNCTION GetXWindowValue(window: WindowPtr): LongInt;
  459.     Inputs    window        Pointer to window associated with the
  460.                  value
  461.     Outputs    customValue    Four byte value containing the 
  462.                 data stored with the window
  463.  
  464. New Callback - "HideHCPalettes"
  465. PROCEDURE HideHCPalettes;
  466.     Inputs    <none>
  467.     Outputs    <none>
  468. This callback hides all currently visible windows, both built-in and 
  469. XWindows.  Additionally, it stores internally which windows were visible 
  470. at the time it was called so that a subsequent call to ShowHCPalettes 
  471. will display the same set of windows.  This callback is commonly used 
  472. when an external command needs to clear the screen such as when using 
  473. the video overlay card.
  474.  
  475. New Callback - "ShowHCPalettes"
  476. PROCEDURE ShowHCPalettes;
  477.     Inputs    <none>
  478.     Outputs    <none>
  479. This callback displays all windows hidden with the HideHCPalettes 
  480. callback.  If HideHCPalettes was not called, this callback does not 
  481. display any windows.
  482.  
  483. New Callback - "SetXWIdleTime"
  484. PROCEDURE SetXWIdleTime(window: WindowPtr; interval: LongInt);
  485.     Inputs    window        Pointer to owner window 
  486.         interval        Length (in ticks) between idle events
  487.     Outputs    <none>
  488. External commands that create XWindows will normally receive xIdleEvt 
  489. events periodically.  Because HyperCard IIgs must spend time generating 
  490. and sending these events, an external command can tell HyperCard IIgs 
  491. how often it wants these events.  Setting the interval to zero will 
  492. cause HyperCard IIgs to not send any idle events.  Setting the interval 
  493. to a very small number will cause HyperCard IIgs to send xIdleEvt events 
  494. as quickly as possible.  Because of the overhead involved in generating 
  495. and sending an event, an external command should not depend on receiving 
  496. xIdleEvt events at exact intervals.  In addition, xIdleEvt events are 
  497. only sent at HyperCard IIgs idle time and may be postponed for lengthy 
  498. intervals while scripts are running.
  499.  
  500. New Callback - "XWAllowReEntrancy"
  501. PROCEDURE XWAllowReEntrancy(window: WindowPtr; allowSysEvts: BOOLEAN; 
  502.              allowHCEvts: BOOLEAN);
  503.     Inputs    window    Pointer to owner window
  504.         allowSysEvts    Whether to allow reentrant system
  505.                  events
  506.         allowHCEvts    Whether to allow reentrant HyperCard 
  507.                 events
  508. External commands have control over whether to allow reentrant events.  
  509. That is, whether to allow an event to be sent to an external that is 
  510. still executing in response to another event.  The default is not to 
  511. allow recursive calls to an external command.
  512.  
  513.  
  514. Events Dealing with XWindows
  515. External commands that create XWindows are kept in memory after they 
  516. terminate so that they may be called in response to events concerning 
  517. the XWindows they created.  An XCMD can determine whether it has been 
  518. called from a script or the message box or in response to an event by 
  519. checking the paramCount field of the parameter block.  If this value is 
  520. negative, the XCMD has been called in response to an event.  The 
  521. following Pascal code fragment illustrates this concept.
  522.  
  523.     BEGIN {SampleXCMD}
  524.       { If the paramCount is negative, we have been called in response 
  525.         to an event }
  526.       IF paramPtr^.paramCount < 0 THEN BEGIN
  527.         HandleEvents;
  528.         EXIT(SampleXCMD);
  529.       END; {if}
  530.  
  531.       { program continues... }
  532.  
  533. The Events an External Command Can Receive
  534. The following is a list of all events an external command can receive 
  535. along with a description of the event.  Some of the events are standard 
  536. system events while others are generated by HyperCard.
  537.  
  538. HyperCard Event - "xOpenEvt"
  539. xOpenEvt is the first event sent to any XWindow.  This event is sent to 
  540. any new XWindows immediately after the parent XCMD terminates.  No 
  541. events will be sent to an XWindow before this event.
  542.  
  543. HyperCard Event - "xCloseEvt"
  544. This is HyperCard's method of notifying the XCMD that a window that it 
  545. created is being closed.  At the time of the event, the window is still 
  546. present and visible.  The window will be closed immediately following 
  547. the event.  The owner XCMD should not call CloseXWindow or close the 
  548. window in any other means when it receives this event.  HyperCard will 
  549. handle closing the window when the XCMD returns control.  XCMDs will 
  550. typically use this event to dispose of any additional memory they have 
  551. allocated for the XWindow.
  552.  
  553. HyperCard Event - "xHidePalettesEvt"
  554. This event is sent to all XWindows when an external command executes the 
  555. HideHCPalettes callback.  An external command may wish to deallocate 
  556. memory or take other action when the user hides their window in this 
  557. manner.
  558.  
  559. HyperCard Event - "xShowPalettesEvt"
  560. This event is sent to all XWindows when an external command executes the 
  561. ShowHCPalettes callback.  An external command may need to prepare itself 
  562. to handle update events, etc, if it has deallocated the memory when 
  563. being hidden.
  564.  
  565. HyperCard Event - "xCursorWith"
  566. This event is sent to an XWindow when the mousecursor enters therect of 
  567. their window.  The owner XCMD can then set the cursor to a custom shape 
  568. if desired using the GS Toolbox.  If they do not wish to handle the 
  569. changing of the cursor shape, the external command should set the 
  570. passFlag of the parameter block to TRUE so that HyperCard IIgs will 
  571. handle the cursor itself.  Since this message is sent repeatedly, as 
  572. long as the cursor is within the window, the XCMD should determine 
  573. whether it has already changed the cursor shape before doing so again to 
  574. avoid flickering of the cursor and slowing down the CPU. 
  575.  
  576. System Event - "UpdateEvt"
  577. This event indicates the all or part of the specified window needs to be 
  578. updated.  It is the responsibilty of the owner external of each window 
  579. to handle redrawing the contents of the window in response to this 
  580. event.
  581.  
  582. System Event - "MouseDownEvt"
  583. The user has pressed the mouse button while the mouse pointer was within 
  584. an external window.  The external command will commonly handle tracking 
  585. the mouse click manually, or call FindControl and have the control 
  586. manager do so.
  587.  
  588. System Event - "NullEvt"
  589. This event will only be sent if the XCMD/XFCN has enabled idle events by 
  590. setting the idle interval to a value other than zero with the 
  591. SetXWIdleTime callback.  See the description of this callback above for 
  592. more information regarding using null events.
  593.  
  594.  
  595. Care and Feeding of Your New XWindow
  596. An XCMD that creates an XWindow is treated differently from an XCMD that 
  597. doesn't.  The following section details differences the XCMD author 
  598. needs to be aware of.
  599.  
  600. 1)  XCMDs that create external windows are kept in memory as long as any 
  601. XWindows that XCMD created are open.
  602. 2)  XWindow XCMDs should not assume that they own only one window.  
  603. Subsequent calls to the XCMD may create additional windows.  The XCMD 
  604. should use the windowPtr passed and the GetXWindowValue and 
  605. SetXWindowValue calls to determine the appropriate action to take in 
  606. response to a particular event.
  607. 3)  The same Memory Manager user ID is passed to an XWindow owner XCMD 
  608. as long as any of the XWindows the XCMD owns are open.  The XCMD should 
  609. not perform a DisposeAll on its memory ID because other windows that the 
  610. XCMD is responsible for could still be open. 
  611. 4)  The wFrameBits field of an XWindow is inaccessible to an XCMD, XCMDs 
  612. should not attempt to modify the standard window attributes of a 
  613. windoid.
  614. 5)  XWindow owners that close all of their XWindows will be disposed of 
  615. when there are no more pending calls to them.
  616.  
  617.  
  618. Major Bug Fixes in HyperCard IIgs 1.1
  619. This section lists the bugs present in version 1.0 that are addressed in 
  620. HyperCard IIgs 1.1.  This is not a complete list of all bug fixes but 
  621. rather a guide to major differences in version 1.0 and version 1.1 that 
  622. a user could encounter.
  623.  
  624. Project Area    Bug Description            Scope of Bug Fix
  625.  
  626. Memory Mgmt.    Last sound played is left in     Version 1.1 now 
  627.         memory locked and unpurgeable     cleans up
  628.         until another sound is played     sounds at idle 
  629.         at which point that sound is     time.
  630.         left locked and unpurgeable.
  631.  
  632. Externals    If an XCMD is passed an argument     Added error check 
  633.          that necessitates leaving the     and recovery for this 
  634.         stack which contains the XCMD,    situation.
  635.         version 1.0 would crash.
  636.  
  637. Interpreter    Internal hash values were not     Localized assembly 
  638.         being generated correctly,     fix.
  639.         slowing HyperTalk
  640.         execution speed.
  641.  
  642. Read Command    Read command could orphan a 4K    Rewrite of Read 
  643.         handle in out of memory conditions.    command.
  644.         Command is also wasteful of 
  645.         memory and inefficient.
  646.  
  647. Clipboard    Version 1.0 was using an         Change to using 
  648.         undocumented scrap type         documented type.
  649.         for palettes.
  650.  
  651. Cursors        Several cases where version     Modified problem  
  652.         1.0 wasn't restoring the cursor     routines to 
  653.         shape correctly.            save/restore 
  654.                         cursor correctly.
  655.  
  656. Edit Menu    Edit Menu IDs off-by-one for DAs.      Modified to use  
  657.         Copy would be Cut, Paste would be     correct values.
  658.         Copy, etc.
  659.  
  660. HyperTalk    Saving a copy of a stack from     Now save the wet 
  661.         HyperTalk while in the Paint     paint on the correct 
  662.         tools with wet paint present    card before the 
  663.          would result in the paint being    copy.
  664.         saved on the first card of the 
  665.         source stack being copied.
  666.  
  667. Paint Tools    Fonts loaded or generated when    Correctly set fonts  
  668.         using paint text were not         as purgeable after
  669.         released.             use.
  670.  
  671. Visual Effects    Using visual effect dissolve     No longer crashes.
  672.         with a completely obscured card 
  673.         window causes a crash.
  674.  
  675. HyperTalk    The Dial command would not     Version 1.1 now 
  676.         utilize a modem or serial card.    looks for a character 
  677.                         device, preferrably 
  678.                          in slot 2, if the 
  679.                         built-in modem port is 
  680.                         overridden.
  681.  
  682. Memory Mgmt.    Internal PLib routine that copies    Patched out PLIB 
  683.         blocks of memory contained a bug    routine with fixed 
  684.         that would overwrite a word of    version.
  685.          memory if the area being copied 
  686.         was an odd number of bytes and 
  687.         crossed a bank.
  688.  
  689. HyperTalk    Using the "write at" syntax of the      This 1.0 bug is fixed  
  690.         write command to write at a point     within Version 1.1
  691.         beyond the eof of a file would not     so that it zeros
  692.         clear the data between the     the data.
  693.         previous eof and the new mark 
  694.         when writing to an AppleShare or 
  695.         HFS volume.  
  696.     
  697. Screen Update    Scrolling a field then moving     Fixed.
  698.         windows over top of it would 
  699.         cause the field to refresh 
  700.         incorrectly.
  701.  
  702. Renaming a Stack    Changing the case of a character    Fixed.
  703.          of the name of a stack would not 
  704.         rename the stack.
  705.     
  706. HyperTalk    Opening a ProDOS 8 application     Now correctly using 
  707.         "with"a document was incorrectly     slashes.
  708.         using colons to specify the 
  709.         document path.
  710.  
  711. HyperTalk    Executing an invalid callback     Now call 
  712.         number would execute a brk     SysFailMgr.
  713.         instruction, exiting to the 
  714.         debugger or monitor.
  715.  
  716. Speed Improvements
  717. Listed below are specific areas that have been improved as far as 
  718. execution speed.  While many improvements within the program as far as 
  719. overall speed and responsiveness have been implemented, this section 
  720. details speed improvements local to a specific area.
  721.  
  722. Project Area    Description of Speed Improvement
  723. Icon Picker    Time to display the icon picker when choosing an icon 
  724.         for a button has been drastically reduced.  Most 
  725.         apparent when displaying many icons as in the Button
  726.          Ideas stack.
  727.  
  728. Interpreter    (Also listed in bug fixes.)  Internal hash values were 
  729.         being generated incorrectly, reducing execution speed. 
  730.          Hash values now generated correctly.
  731.  
  732. Interpreter    Internal interpreter routines rewritten in assembly.
  733.  
  734. Graphics        Internal picture unpacking algorithm rewritten in 
  735.         assembly for improved speed.
  736.  
  737. Button Hiliting    Version 1.0 writes the hilite of auto-hilite buttons to
  738.          disk every time they are clicked regardless of whether
  739.          the button actually changed state.  HyperCard IIGS
  740.          version 1.1 only writes auto-hilite buttons to disk if 
  741.         the state actually changes, saving a disk  access for 
  742.         every mouse click.
  743.  
  744. Button/Fields    Button and field drawing code is now all assembly.
  745.  
  746.  
  747. Code Size/Memory Usage
  748. HyperCard IIgs version 1.1 is smaller in code size than HyperCard IIGS 
  749. version 1.0 even with the addition of the new features because version 
  750. 1.1 is compiled with a later version of the Pascal IIGS compiler which 
  751. generates smaller/faster code and because of routines rewritten in 
  752. assembly which is inherently smaller than most compiled Pascal code as 
  753. well as more efficient.  Optimizing of Pascal code has also resulted in 
  754. smaller code size and memory usage.
  755.  
  756. Version 1.1 manages memory more efficiently and will work better than 
  757. version 1.0 in low memory situations because of the memory management 
  758. bugs fixed as noted above and because of reorganized global variable 
  759. usage and new code segmentation used throughout the program.
  760.  
  761.  
  762.  
  763. Sample XWindow Code (Pascal)
  764. Included below is the source code for a sample XCMD.  This is a much 
  765. simplified version of the Picture XCMD that appears in the Scripter's 
  766. Tools stack.  The complete source to that XCMD is also available as 
  767. sample source code.
  768.  
  769. {---------------------------------------------------------------------
  770.  
  771.   file Picture.p
  772.   
  773.   Part of HyperCard IIGS 1.1
  774.  
  775.   Copyright c 1991 Apple Computer, Inc.
  776.  
  777.   This XCMD has the following syntax:
  778.     Picture resName [, windowStyle]
  779.     
  780.     INPUTS:    resName    Name of pict resource to draw in the window
  781.         windowStyle    (Optional)  Defines the appearance of the
  782.                  picture window.  Can be rect, rectangle,
  783.                 shadow, or dialog.  Any other text or not
  784.                 specified results in a standard windoid.
  785.                             
  786.   This XCMD creates and maintains an XWindow.  The XWindow contains
  787.   a picture retrieved from a resource with a name specified by the
  788.   caller.  If the resource cannot be found, the XWindow is still
  789.   created and the text "Unable to draw picture." is displayed.
  790.   
  791.   Author:    Darin Acquistapace
  792.   Created:    5/22/91
  793.   Modified:    See Mod History Below
  794.  
  795.  
  796.   Modification History:
  797.  
  798.     5/22/91 - New today.
  799.     5/30/91- Updated for revised XWindow callbacks
  800.     6/04/91 - Added HyperCard version check.
  801.     6/12/91 - Changed from wInContent to mouseDownEvt for mouseDowns.
  802.     6/14/91 - Added XWAllowReEntrancy for release with 1.1d10.
  803.     6/24/91 - Modified to work with "real" custom defProc XWindows.
  804.     6/31/91 - Added support for xCursorWithin message.
  805.     8/19/91 - Added support for multiple window styles.
  806.     
  807. ---------------------------------------------------------------------}
  808.  
  809. UNIT DummyUnit;
  810.  
  811. {$Z+ }
  812. {$N+ }
  813.  
  814. INTERFACE
  815.  
  816. USES     
  817.   Types, Memory, MiscTool, GSOS, QuickDraw, Resources, QDAux, Events, 
  818.   Controls, Windows, Menus, HyperXCMD;
  819.      
  820. PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  821.  
  822. IMPLEMENTATION
  823.  
  824. PROCEDURE XPicture(paramPtr: XCmdPtr);                
  825.     FORWARD;
  826.  
  827. PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  828. BEGIN
  829.   XPicture(paramPtr);
  830. END;
  831.  
  832. PROCEDURE XPicture(paramPtr: XCmdPtr);
  833. CONST
  834.     ScriptErrStr    = 'Can''t understand arguments of XCMD 
  835. Picture.';
  836.     CopyrightStr    = 'Picture XCMD v1.0d7" & return & 
  837.                   "by Darin Acquistapace, 5/22/91" & return 
  838.                    & "c 1991 Apple Computer, Inc.';
  839.     HelpStr        = 'FORM:  Picture ResourceName [, windowStyle]';
  840.     WrongVersionStr     = 'Picture XCMD requires HyperCard IIGS 1.1';
  841.     CreateErrStr    = 'Unable to create window';
  842.     CantDrawStr        = 'Unable to draw picture.';
  843.     RectStr1        = 'rect';
  844.     RectStr2        = 'rectangle';
  845.     ShadowStr        = 'shadow';
  846.     DialogStr        = 'dialog';
  847. VAR
  848.     pCount:        INTEGER;
  849.     windowStyle:    INTEGER;
  850.     sampleXWindow:    WindowPtr;
  851.     windRect:        Rect;
  852.     str:            Str255;
  853.     styleStr:        Str255;
  854.     
  855.     PROCEDURE HTError;
  856.     { Puts the specified string into the result and terminates with a 
  857.         HyperTalk error}
  858.     BEGIN
  859.       ParamPtr^.ReturnValue := PasToZero(ScriptErrStr);
  860.       ParamPtr^.ReturnStat := 1;
  861.       EXIT(XPicture);
  862.     END; {HTError}
  863.     
  864.     PROCEDURE ReturnResult(str: Str255);
  865.     { Puts the specified string into the result and terminates }
  866.     BEGIN
  867.       ParamPtr^.ReturnValue := PasToZero(str);
  868.       EXIT(XPicture);
  869.     END; {ReturnResult}
  870.     
  871.     PROCEDURE CommandInfo(Msg : str255);
  872.     { Puts the specified string into a dialog box and terminates }
  873.     BEGIN
  874.       SendHCmessage(concat('answer "', Msg, '"')); 
  875.       EXIT(XPicture);
  876.     END; {CommandInfo}
  877.  
  878.  
  879.     PROCEDURE UpdatePicture(whichWindow: WindowPtr);
  880.     { This draws our picture into the XWindow }
  881.     VAR
  882.       myPictureHndl: LongInt;
  883.       destRect:     Rect;
  884.     BEGIN
  885.       
  886.       { Retrieve the handle to our picture }
  887.       myPictureHndl := GetXWindowValue(whichWindow);
  888.       
  889.       { Display message if unable to load the picture }
  890.       IF myPictureHndl = 0 THEN BEGIN
  891.         WITH whichWindow^.portRect DO SetRect(destRect, 0, 0, right, 
  892.                                 bottom);
  893.         EraseRect(destRect);
  894.         MoveTo(10,13);
  895.         DrawString(CantDrawStr);
  896.          EXIT(UpdatePicture);
  897.         END; {if}
  898.       
  899.       { Draw picture in upper left corner }
  900.       WITH PicHndl(myPictureHndl)^^.picFrame DO 
  901.         SetRect(destRect, 0, 0, right-left, bottom-top);
  902.       DrawPicture(PicHndl(myPictureHndl), destRect);
  903.     END; {UpdatePicture}
  904.  
  905.  
  906.     PROCEDURE CleanUpMemory(whichWindow: WindowPtr);
  907.     { Remove our picture from memory when we close }
  908.     VAR
  909.       myPictureHndl:  LongInt;
  910.     BEGIN
  911.       myPictureHndl := GetXWindowValue(whichWindow);
  912.       IF myPictureHndl = 0 THEN EXIT(CleanUpMemory);
  913.       KillPicture(PicHndl(myPictureHndl));
  914.       SetXWindowValue(whichWindow, 0);   { Just to be safe - clear 
  915.                                 this value }
  916.     END; {CleanUpMemory}
  917.     
  918.     
  919.     PROCEDURE HandleWindowClick(whichWindow: WindowPtr; ourEvent: 
  920.                         EventRecord);
  921.     { The user has clicked in our window, handle tracking the click }
  922.       
  923.       FUNCTION MouseUpInWindow: BOOLEAN;
  924.       { Handle tracking a mouseClick in our window }
  925.       VAR
  926.         mouseLoc:     Point;
  927.         oldInWind:    BOOLEAN;
  928.         inWind:    BOOLEAN;
  929.         targetRect:    Rect;
  930.       BEGIN
  931.         oldInWind := FALSE;
  932.         inWind := TRUE;
  933.         WITH whichWindow^.portRect DO SetRect(targetRect, 0, 0, right, 
  934.                                 bottom);
  935.         REPEAT
  936.           IF oldInWind <> inWind THEN BEGIN
  937.         InvertRect(targetRect);
  938.         oldInWind := inWind;
  939.           END; {if}
  940.           GetMouse(mouseLoc);
  941.           inWind := PtInRect(mouseLoc, targetRect);
  942.         UNTIL NOT Button(0);
  943.         IF oldInWind THEN InvertRect(targetRect);    {Turn off hilite}
  944.         MouseUpInWindow := inWind;  { Return whether mouseUp occurred 
  945.                             in the rect }
  946.       END; {MouseUpInWindow}
  947.       
  948.     BEGIN
  949.       IF MouseUpInWindow THEN SendHCMessage('play "Harpsichord" tempo 
  950.                                 400 "c d e"');
  951.     END; {HandleWindowClick}
  952.     
  953.  
  954.     PROCEDURE HandleEvents;
  955.     { Handle events specific to our XWindow }
  956.     VAR
  957.       myEventInfo:    XWEventInfoPtr;
  958.       window:    WindowPtr;
  959.       event:        EventRecord;
  960.     BEGIN
  961.         myEventInfo := XWEventInfoPtr(paramPtr^.params[1]);
  962.         window := myEventInfo^.eventWindow;
  963.         event := myEventInfo^.event;
  964.       
  965.        CASE event.what OF
  966.          xOpenEvt:        XWAllowReEntrancy(window, TRUE, TRUE);
  967.          updateEvt:        UpdatePicture(window);
  968.          mouseDownEvt:    HandleWindowClick(window, event);
  969.            xCloseEvt:        CleanUpMemory(window);
  970.          xCursorWithin:    paramPtr^.passFlag := TRUE;  { Let HC 
  971.                                 change our cursor }
  972.        END; {case}
  973.     END; {HandleEvents}
  974.  
  975.  
  976.     PROCEDURE SetUpContents(resName: Str255);
  977.     { Create the contents of our window }
  978.     VAR
  979.       myPictureHndl:  PicHndl;
  980.       homeFile:      INTEGER;
  981.       pictureID:      LongInt;
  982.     BEGIN
  983.       IF NOT FindNamedResource(rPicture, resName, homeFile, pictureID) 
  984. THEN
  985.         EXIT(SetUpContents);
  986.       Handle(myPictureHndl) := LoadResource(rPicture, pictureID);
  987.       IF _toolErr <> 0 THEN EXIT(SetUpContents);
  988.       DetachResource(rPicture, pictureID);
  989.       IF _toolErr <> 0 THEN BEGIN
  990.         ReleaseResource(3, rPicture, pictureID);
  991.         EXIT(SetUpContents);
  992.        END; {if}
  993.       { Have HyperCard save handle to our picture resource }
  994.       SetXWindowValue(sampleXWindow, LongInt(myPictureHndl));
  995.     END; {HandleEvents}
  996.     
  997.     
  998.     FUNCTION CorrectVersion: BOOLEAN;
  999.     { This returns true if the version of HyperCard is >= minVersion }
  1000.     CONST
  1001.       minVersion = '1.1';
  1002.     VAR
  1003.       tempHandle:    Handle;
  1004.       tempStr:    Str255;
  1005.     BEGIN
  1006.       tempHandle := EvalExpr('the version');
  1007.       ZeroToPas(tempHandle^, tempStr);
  1008.       IF temphandle <> NIL THEN DisposeHandle(tempHandle);
  1009.       CorrectVersion := tempStr >= minVersion;
  1010.     END; {CorrectVersion}
  1011.     
  1012.  
  1013.   BEGIN
  1014.     pCount := paramPtr^.paramCount;
  1015.  
  1016.     { If the paramCount is negative, we have been called in response 
  1017.         to an event }
  1018.     IF pCount < 0 THEN BEGIN
  1019.       HandleEvents;
  1020.       EXIT(XPicture);
  1021.     END; {if}
  1022.  
  1023.     
  1024.     { Display help or copyright info in response to "?" or "!" }
  1025.     IF pCount >= 1 THEN BEGIN
  1026.       ZeroToPas(paramPtr^.params[1]^, str);
  1027.       IF str = '!' THEN CommandInfo(CopyrightStr);
  1028.       IF str = '?' THEN CommandInfo(HelpStr);
  1029.     END; {if}
  1030.     
  1031.     { We''ll take one or two parameters }
  1032.     IF (pCount < 1) OR (pCount > 2) THEN HTError;
  1033.  
  1034.     {Make sure we are running at least version 1.1 of HyperCard IIGS}
  1035.     IF NOT CorrectVersion THEN ReturnResult(WrongVersionStr);
  1036.     
  1037.     IF pCount = 1 THEN windowStyle := xWindoidStyle
  1038.     ELSE BEGIN
  1039.       ZeroToPas(paramPtr^.params[2]^, styleStr);
  1040.       IF StringEqual(styleStr, RectStr1) THEN windowStyle := 
  1041.                                         xRectStyle
  1042.       ELSE IF StringEqual(styleStr, RectStr2) THEN windowStyle := 
  1043.                                         xRectStyle
  1044.       ELSE IF StringEqual(styleStr, ShadowStr) THEN windowStyle := 
  1045.                                         xShadowStyle
  1046.       ELSE IF StringEqual(styleStr, DialogStr) THEN windowStyle := 
  1047.                                         xDialogStyle
  1048.       ELSE windowStyle := xWindoidStyle;
  1049.     END; {else}
  1050.     
  1051.     SetRect(windRect, 50, 76, 250, 140);
  1052.     sampleXWindow := NewXWindow(windRect, str, FALSE, windowStyle);
  1053.     IF sampleXWindow = NIL THEN ReturnResult(CreateErrStr);
  1054.     
  1055.     SetUpContents(str);    { Create the contents for the window }
  1056.     
  1057.     ShowWindow(sampleXWindow);
  1058.   END;
  1059.  
  1060. END.    { of the dummy unit    }
  1061.